From: Matthieu Gallien Date: Wed, 23 Apr 2025 16:26:54 +0000 (+0200) Subject: fix(rename): avoid hitting runtime assert when renaming virtual files X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2^2~8^2 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22Program/%22http:/www.example.com/cgi/%22https:/%22Program?a=commitdiff_plain;h=22862556353b10bf6541c4e39b580ea141157a9d;p=nextcloud-desktop.git fix(rename): avoid hitting runtime assert when renaming virtual files when propagating a rename to the child items, we must not make child items be done from propagator point of view they will be part of their own propagator item and that will create issues Signed-off-by: Matthieu Gallien --- diff --git a/src/libsync/propagatorjobs.cpp b/src/libsync/propagatorjobs.cpp index 59b7ec9c9..6711685a3 100644 --- a/src/libsync/propagatorjobs.cpp +++ b/src/libsync/propagatorjobs.cpp @@ -490,12 +490,10 @@ void PropagateLocalRename::start() SyncJournalFileRecord oldRecord; if (!propagator()->_journal->getFileRecord(oldFileNameString, &oldRecord)) { qCWarning(lcPropagateLocalRename) << "Could not get file from local DB" << oldFileNameString; - done(SyncFileItem::NormalError, tr("Could not get file %1 from local DB").arg(oldFileNameString), OCC::ErrorCategory::GenericError); return; } if (!propagator()->_journal->deleteFileRecord(oldFileNameString)) { qCWarning(lcPropagateLocalRename) << "could not delete file from local DB" << oldFileNameString; - done(SyncFileItem::NormalError, tr("Could not delete file record %1 from local DB").arg(oldFileNameString), OCC::ErrorCategory::GenericError); return; } @@ -503,7 +501,6 @@ void PropagateLocalRename::start() newItem->_file = newFileNameString; const auto result = propagator()->updateMetadata(*newItem); if (!result) { - done(SyncFileItem::FatalError, tr("Error updating metadata: %1").arg(result.error()), OCC::ErrorCategory::GenericError); return; } }); diff --git a/test/testsynccfapi.cpp b/test/testsynccfapi.cpp index 20f509cb6..b34b480c0 100644 --- a/test/testsynccfapi.cpp +++ b/test/testsynccfapi.cpp @@ -1486,6 +1486,35 @@ private slots: QVERIFY(itemInstruction(completeSpy, odtFile, CSYNC_INSTRUCTION_UPDATE_METADATA)); QCOMPARE(*vfs->pinState(odtFile), PinState::Unspecified); } + + void renameOnBothSides() + { + FakeFolder fakeFolder { FileInfo::A12_B12_C12_S12() }; + auto vfs = setupVfs(fakeFolder); + + // Test that renaming a file within a directory that was renamed on the other side actually do a rename. + + // 1) move the folder alphabetically before + fakeFolder.remoteModifier().rename("A/a1", "A/a1m"); + fakeFolder.localModifier().rename("A", "_A"); + fakeFolder.localModifier().rename("B/b1", "B/b1m"); + fakeFolder.remoteModifier().rename("B", "_B"); + + QVERIFY(fakeFolder.syncOnce()); + QCOMPARE(fakeFolder.currentRemoteState(), fakeFolder.currentRemoteState()); + QVERIFY(fakeFolder.currentRemoteState().find("_A/a1m")); + QVERIFY(fakeFolder.currentRemoteState().find("_B/b1m")); + + // 2) move alphabetically after + fakeFolder.remoteModifier().rename("_A/a2", "_A/a2m"); + fakeFolder.localModifier().rename("_B/b2", "_B/b2m"); + fakeFolder.localModifier().rename("_A", "S/A"); + fakeFolder.remoteModifier().rename("_B", "S/B"); + QVERIFY(fakeFolder.syncOnce()); + QCOMPARE(fakeFolder.currentRemoteState(), fakeFolder.currentRemoteState()); + QVERIFY(fakeFolder.currentRemoteState().find("S/A/a2m")); + QVERIFY(fakeFolder.currentRemoteState().find("S/B/b2m")); + } }; QTEST_GUILESS_MAIN(TestSyncCfApi)